package com.qianfeng.zhangwei.sybl.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.RadioGroup;

import com.qianfeng.zhangwei.sybl.BaseApp;
import com.qianfeng.zhangwei.sybl.R;
import com.qianfeng.zhangwei.sybl.fragment.ActivityFragment;
import com.qianfeng.zhangwei.sybl.fragment.GameFragment;
import com.qianfeng.zhangwei.sybl.fragment.GiftFragment;
import com.qianfeng.zhangwei.sybl.fragment.MeFragment;
import com.qianfeng.zhangwei.sybl.fragment.TestFragment;
import com.qianfeng.zhangwei.sybl.utils.FragmentTabUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 实现自动轮播的方式
 *
 * 1 > Viewpager + Timer
 *
 * 2>  利用第三方的开源库
 */
public class MainActivity extends BaseActivity implements View.OnClickListener, FragmentTabUtils.OnRgsExtraCheckedChangedListener {
    FragmentTabUtils tabUtils;
    private RadioGroup rgs;
    private List<Fragment> fragments = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rgs = (RadioGroup) this.findViewById(R.id.main_rgs);
        fragments.add(new GiftFragment());
        fragments.add(new ActivityFragment());
        fragments.add(new GameFragment());
        fragments.add(new TestFragment());
        fragments.add(MeFragment.newInstance(""));
        tabUtils = new FragmentTabUtils(getSupportFragmentManager(), fragments, R.id.fragment_main_container, rgs);
        tabUtils.setOnRgsExtraCheckedChangedListener(this);
        aHolder.showGiftlTitle();


    }


    @Override
    public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {
        switch (index) {
            case 0:
                aHolder.showGiftlTitle();
                break;
            case 1:
                aHolder.showActivityTitle();
                break;
            case 2:
                aHolder.showGameAndMoneyTitle();
                break;
            case 3:
                aHolder.showGameAndMoneyTitle();
                break;
            case 4:
                aHolder.showMeTitle();
                break;
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    public void onClick(View v) {
        BaseApp.getInstance().showToast("别点索搜功能没做");
    }
}
